package com.xdcplus.web.common.enums;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public enum DefectDeviceTypeEnum {
    // 数据操作错误定义
    PL("PL", "PL"),
    IV("IV", "IV"),
    FB("FB", "正背检"),
    EL("EL", "EL"),
    CRACK("CRACK", "利珀检测"),

    ;
    public static List<DefectDeviceTypeEnum> sortByValue() {
        return Stream.of(values())
                .sorted(Comparator.comparing(DefectDeviceTypeEnum::getCode))
                .collect(Collectors.toList());
    }
    private String code;

    private String msg;

    public static String getMsg(String code) {
        for (DefectDeviceTypeEnum ele : values()) {
            if(ele.getCode().equals(code)) {return ele.getMsg();}
        }
        return null;
    }

    DefectDeviceTypeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
